package star.cloud.asme.flowable.processInstance;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.runtime.ProcessInstance;
import org.springframework.web.bind.annotation.*;
import star.cloud.asme.base.dto.Result;
import star.cloud.asme.base.fowable.baseInterface.FlowableBaseController;
import star.cloud.asme.base.fowable.VO.ProcessInstanceQueryCondition;
import star.cloud.asme.base.fowable.VO.ProcessInstanceVO;
import star.cloud.asme.flowable.processInstance.DTO.*;

@RestController
@RequestMapping("/flowable/processInstance")
@RequiredArgsConstructor
@Slf4j
public class HqProcessInstanceController implements FlowableBaseController<ProcessInstanceQueryCondition, ProcessInstanceVO> {

    private final HqProcessInstanceService hqProcessInstanceService;

    @Override
    public Result<ProcessInstanceVO> getOneByCondition(@PathVariable String key, @PathVariable Object value) {
        return hqProcessInstanceService.getOneByCondition(key, value);
    }

    @Override
    public Result<ProcessInstanceVO> getOneByConditions(ProcessInstanceQueryCondition conditions) {
        return hqProcessInstanceService.getOneByConditions(conditions);
    }

    @Override
    public Result<IPage<ProcessInstanceVO>> getListByConditionsWithPage(ProcessInstanceQueryCondition conditions) {
        return hqProcessInstanceService.getListByConditionsWithPage(conditions);
    }


    @PostMapping("/startProcessInstanceById")
    Result<ProcessInstance> startProcessInstanceById(StartProcessInstanceParams startProcessInstanceParams) {
        return hqProcessInstanceService.startProcessInstanceById(startProcessInstanceParams);
    }

    @Override
    public Result<?> logicalDeleteById(String id) {
        return hqProcessInstanceService.logicalDeleteById(id);
    }

    @Override
    public Result<?> physicalDeleteById(String id) {
        return hqProcessInstanceService.physicalDeleteById(id);
    }
}
